/*
 * @Description: 你的代码我的心
 * @Author: GGB
 * @Date: 2021-12-27 09:57:24
 * @LastEditors: GGB
 * @LastEditTime: 2022-01-22 15:47:31
 */

// import { h } from 'vue';
import { getExpressList } from '/@/api/express';
import { FormSchema } from '/@/components/Table';

// 物流发货
export const deliverySchemas: FormSchema[] = [
  {
    field: 'express_id',
    label: '物流公司',
    component: 'Select',
    rules: [{ required: true, message: '请选择物流公司' }],

    componentProps: async () => {
      // 网络请求
      const data = await getExpressList();
      const list = data.list.data;
      const options = list.map((v) => {
        v.label = v.express_name;
        v.value = `${v.express_id}`;
      });
      return { options, placeholder: '请选择物流公司' };
    },

    colProps: { span: 24 },
  },

  {
    field: 'express_no',
    component: 'Input',
    label: '物流单号',
    helpComponentProps: {
      text: '请填写发货的物流或快递单号',
    },
    colProps: {
      span: 24,
    },
    rules: [{ required: true, message: '请选择物流公司' }],
    componentProps: {
      placeholder: '请输入物流单号',
    },
  },
];

// 修改价格
export const updatePriceSchemas: FormSchema[] = [
  {
    field: 'order_price',
    component: 'Input',
    label: '订单金额',
    colProps: {
      span: 24,
    },
    rules: [{ required: true, message: '请输入订单金额' }],
    componentProps: {
      placeholder: '请输入姓名',
      extra: '最终付款金额 = 订单金额 + 运费金额',
      min: 0.01,
      precision: 2,
    },
  },
  {
    field: 'express_price',
    component: 'Input',
    label: '运费金额',
    colProps: {
      span: 24,
    },
    rules: [{ required: true, message: '请输入配送价格' }],
    componentProps: {
      placeholder: '请输入配送价格',
      min: 0.01,
      precision: 2,
    },
  },
];

// 审核取消订单
export const cancelSchemas: FormSchema[] = [
  {
    field: 'pay_price',
    component: 'Input',
    label: '实付款金额',
    colProps: {
      span: 24,
    },
    render: ({ model, field }) => {
      return <span>{model[field]}</span>
      // return h('span', `${model[field]}`);
    },
  },
  {
    field: 'status',
    defaultValue: 1,
    component: 'RadioGroup',
    label: '审核状态',
    colProps: {
      span: 24,
    },
    componentProps: {
      options: [
        { label: '同意', value: 1 },
        { label: '拒绝', value: 0 },
      ],
    },
  },
];
